// pages/project/project.js
var request = require("../../utils/request.js")
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    info:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.toastDialog = this.selectComponent("#toastDialog");//此处id和页面的 wxml中的id一致
    this.queryProject(options)
    console.log(options)
    wx.showShareMenu({ menus: ['shareAppMessage', 'shareTimeline']})
  },
/**
 * 用户点击右上角分享
 */
onShareAppMessage (res) {
  return {
    title: '迪佳极视',
    path: 'pages/index/index',
    // imageUrl:'这个是显示的图片，不写就默认当前页面的截图',
    success: function (shareTickets) {
      console.info(shareTickets + '成功');
      // 转发成功
    },
    fail: function (res) {
      console.log(res + '失败');
      // 转发失败
    },
    complete:function(res){
      // 不管成功失败都会执行
    }
  }
},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  queryProject:function(options){
    var that = this;
    that.toastDialog.showDialog({ code: 'loading', message: '加载中', timeout: false }); //loading 加载框
    request.postData('xcx/projectInfo', options, function (res) {
      that.toastDialog.hideDialog(); //关闭loading提示框
      if (res.code == 0) {
        that.setData({
          info: res.info
        })
      }else{
        that.toastDialog.showDialog({ code: res.code, message: res.message, timeout: true });
      }
    }, function (res) {
      that.toastDialog.showDialog({ code: res.code, message: res.message, timeout: true });
    });
  }
})